import { load } from "/admin/util/LoadView.js";
load('adduser');

let photo = ''
adduserform.onsubmit = async function (e) {
    e.preventDefault();

    // console.log(photo)
    await fetch('http://localhost:3000/users', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            username: username.value,
            password: password.value,
            userintro: userintro.value,
            photo
        })
    }).then(res => res.json())

    location.href = '/admin/views/userManage/userList/index.html'
}
photofile.onchange = function (evt) {
    let reader = new FileReader()
    reader.readAsDataURL(evt.target.files[0])
    reader.onload = function (e) {
        photo = e.target.result
    }
}